import 'package:flutter/material.dart';

class AllPage extends StatefulWidget {
  _AllPageState createState() => _AllPageState();
}

class _AllPageState extends State<AllPage> with AutomaticKeepAliveClientMixin {
  @override
  // TODO: implement wantKeepAlive
  bool get wantKeepAlive => true;

  @override
  Widget build(BuildContext context) {
    super.build(context);
    double width = MediaQuery.of(context).size.width;
    double itemW = (width - 60) / 3.0;
    double itemH = (itemW / 0.8) + 45;
    return Column(
      children: [
        Divider(
          height: 20,
        ),
        Expanded(
          child: GridView.builder(
            itemCount: 10,
            padding: EdgeInsets.only(left: 15, right: 15),
            gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
              crossAxisCount: 3,
              mainAxisSpacing: 10,
              crossAxisSpacing: 10,
              mainAxisExtent: itemH,
            ),
            itemBuilder: (context, index) {
              return Container(
                child: Column(
                  crossAxisAlignment: CrossAxisAlignment.start,
                  children: [
                    ClipRRect(
                      child: Container(
                        color: Colors.red,
                        height: itemH - 45,
                      ),
                      borderRadius: BorderRadius.circular(10),
                    ),
                    Divider(
                      height: 5,
                    ),
                    Text(
                      '哈哈哈哈哈',
                      style: TextStyle(color: Colors.white, fontSize: 14),
                      softWrap: true,
                      maxLines: 2,
                    ),
                  ],
                ),
              );
            },
          ),
        ),
      ],
    );
  }
}
